package com.clkj.zhonghui.dao.user;

import com.clkj.zhonghui.pojo.user.User;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Options;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;
import org.springframework.stereotype.Repository;
import tk.mybatis.mapper.common.Mapper;

import java.util.Map;

/**
 * @author yawang
 * @create 2024/07/19 09:36:59
 **/
@Repository
public interface UserMapper extends Mapper<User> {
    @Insert("insert into t_zh_user values (#{userName},#{userImg},#{openId},#{shopId},#{unionId},#{userTel},#{shareId},#{ifDown},#{registerTime},#{referrerId})")
    @Options(useGeneratedKeys = true, keyProperty = "userId")
    void addUser(User user);


    @Select("select user_id from t_zh_user where unionId = #{unionid}")
    Map<String, Object> getUserByunionid(String unionid);

    @Select("select user_id from t_zh_user where openId = #{openId}")
    Map<String, Object> getUserByopenId(String openId);

    @Select("select * from t_zh_user where user_id = #{userId}")
    User getUserId(Integer userId);

    @Update("update t_zh_user set referrer_id = 0  where user_id = #{userId}")
    void unbindUser(Integer userId);

    @Update("update t_zh_user set user_tel = #{userTel},user_name = #{name} where user_id = #{userId}")
    void editUsernameAndTf(String userTel, String name, Integer userId);
}
